package org.zjt.hessian.demo.server;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.caucho.HessianServiceExporter;
import org.zjt.hessian.demo.common.service.HelloService;

/**
 * 将spring bean 加入到hessian的IOC容器中。
 */
@Configuration
public class HessianExporterConfig {

    @Autowired
    private HelloService helloService;

    @Value("${hessian.hello-server.url}")
    private String serverUrl ;


    /**
     *  声明HessianServiceExporter的url为/HelloService
     */
    @Bean(name = "/HelloService")
    public HessianServiceExporter accountService() {
        HessianServiceExporter exporter = new HessianServiceExporter();
        exporter.setService(helloService);
        exporter.setServiceInterface(HelloService.class);
        return exporter;
    }

}
